package com.fancy.learncenter.adapter;

import android.content.Context;
import android.content.Intent;
import android.text.Html;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.activity.H5Activity;
import com.fancy.learncenter.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.adapter.base.CustomViewHold;
import com.fancy.learncenter.bean.TrainListDataBean;
import com.fancy.learncenter.utils.LogUtil;
import com.fancy.learncenter.utils.Utils;
import com.journeyapps.barcodescanner.Util;
import com.superservice.lya.R;

import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URLDecoder;
import java.util.ArrayList;

import okhttp3.HttpUrl;

/**
 * Created by hyy on 2018/2/24.
 * Explain activity as
 */

public class TrainLiveVideoAdapter extends CommonRecycleViewAdapter<TrainListDataBean> {

    public TrainLiveVideoAdapter(Context mContext, ArrayList<TrainListDataBean> itemDatas) {
        super(mContext, R.layout.fragment_train_video_item, itemDatas);
    }


    @Override
    public void bindView(CustomViewHold customViewHold, final TrainListDataBean item, int position) {
        SimpleDraweeView simpleDraweeView = customViewHold.getView(R.id.simpleDraweeView);
        simpleDraweeView.setImageURI(item.getImgsrc());


        TextView author = customViewHold.getView(R.id.author);
        author.setText(item.getAuthor());

        TextView play_num = customViewHold.getView(R.id.play_num);
        play_num.setText(item.getPlayed_num() + "次播放");

        TextView title = customViewHold.getView(R.id.title);
        title.setText(item.getContent());

        customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, H5Activity.class);

                intent.putExtra(H5Activity.URL_KEY, Html.fromHtml(item.getLive_site()).toString());

                mContext.startActivity(intent);

            }
        });
    }


}
